package cn.com.hori.cms.controller;

import cn.com.hori.cms.entities.ContentPublish;
import cn.com.hori.cms.model.CommonResponse;
import cn.com.hori.cms.service.ContentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 内容推送  的 contorller
 *
 * @author 刘艺
 * @date 2018/3/8 15:11
 */
@RestController
@RequestMapping("/smc/content")
public class ContentContorller {
    private static Logger logger = LoggerFactory.getLogger(ContentContorller.class);

    @Autowired
    private ContentService contentService;

    @GetMapping("/getContent")
    public CommonResponse getAllContent(@RequestParam String columnId, @RequestParam Integer page, @RequestParam Integer size) {
        return new CommonResponse<>(contentService.getAllContent(columnId, page, size));

    }

    @PostMapping("/updateContent")
    public CommonResponse updateContent(@RequestBody ContentPublish contentPublish) {
        return new CommonResponse<>(contentService.upadateContent(contentPublish));
    }

    @PostMapping("/deleteContent")
    public CommonResponse deleteContent(@RequestBody ContentPublish contentPublish) {
        return new CommonResponse<>(contentService.delete(contentPublish));
    }
}
